#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 1e5 + 10;
int n, st, A, B;
vector<int> g[N];

namespace solvelian{
	int v[N], f[N];
	struct seg{
		int t[N*4];
		void add(int p, int l, int r, int x, int v){
			if(l == r){
				t[p] = v;
			} else {
				int mid = l + r >> 1;
				if(x <= mid){
					add(p<<1, l, mid, x, v);
				} else {
					add(p<<1|1, mid+1, r, x, v);
				}
				t[p] = min(t[p<<1], t[p<<1|1]);
			}
		}
		int ask(int p, int l, int r, int ql, int qr){
			if(qr < l || r < ql){
				return 1e9;
			} else if(ql <= l && r <= qr){
				return t[p];
			} else {
				int mid = l + r >> 1;
				return min(ask(p<<1, l, mid, ql, qr), ask(p<<1|1, mid+1, r, ql, qr));
			}
		}
	} t1, t2;
	int main(){
		memset(t1.t, 0x3f, sizeof(t1.t));
		memset(t2.t, 0x3f, sizeof(t2.t));
		memset(f, 0x3f, sizeof(f));
		v[1] = st;
		t1.add(1, 1, n, 1, st);
		for(int i = 2, la = st, nw = 0; i <= n; ++ i){
			nw = 0;
			for(auto j : g[la]){
				if(j != la){
					nw = j;
				}
			}
			v[i] = la = nw;
			t1.add(1, 1, n, i, nw);
		}
		for(int i = n; i >= 1; -- i){
			if(n - i >= A){
				f[i] = min(t1.ask(1, 1, n, i+A-B, i+A-1), t2.ask(1, 1, n, i+A, min(n, i+A+B)));
				t2.add(1, 1, n, i, f[i]);
			} else {
				f[i] = t1.ask(1, 1, n, i, min(n, i+B));
				t2.add(1, 1, n, i, f[i]);
			}
			// printf("%d %d\n", i, f[i]);
		}
		printf("%lld\n", f[1]);
		return 0;
	}
}

namespace solve2{
	int f[3010], ff[3010][3010], dep[3010], anc[3010];
	vector<int> geta[3010], sonb[3010];
	int getaa[3010];
	int isson[3010][3010];
	void prdfs(int x, int fa){
		// printf("%d %d\n", x, fa);
		dep[x] = dep[fa] + 1;
		anc[x] = fa;
		if(dep[x] > A){
			int p = x;
			for(int i = 1; i <= A; ++ i){
				p = anc[p];
			}
			// printf("geta %d %d\n", p, x);
			geta[p].push_back(x);
		}
		if(dep[x] >= A){
			int p = x;
			for(int i = 1; i < A; ++ i){
				p = anc[p];
			}
			getaa[x] = p;
		}
		int p = x;
		for(int i = 1; i <= B; ++ i){
			p = anc[p];
			if(p) sonb[p].push_back(x);
		}
		p = x;
		isson[x][x] = 1;
		for(int i = 1; i <= B; ++ i){
			p = anc[p];
			isson[p][x] = 1;
		}
		for(int i : g[x]){
			if(i != fa){
				prdfs(i, x);
			}
		}
	}
	int vis[N];
	pair<int, int> dddd(int ac, int x, int dep){
		if(dep == B + 1) return make_pair(1e9, 0);
		pair<int, int> mn = make_pair(x, ac);
		for(int i : g[x]){
			if(i == anc[x]) continue;
			mn = min(mn, dddd(ac, i, dep+1));
		}
		return mn;
	}
	void cal(int x){
		if(vis[x]) return;
		vis[x] = 1;
		if(geta[x].empty()){
			pair<int, int> mn, cmn;
			mn = cmn = make_pair(1e9, 0);
			for(int i : g[x]){
				if(i == anc[x]) continue;
				pair<int, int> tmp = dddd(i, i, 1);
				if(tmp <= mn){
					cmn = mn;
					mn = tmp;
				} else {
					cmn = min(cmn, tmp);
				}
			}
			f[x] = min(x, mn.first);
			for(int i : g[x]){
				if(i == anc[x]) continue;
				if(mn.second == i){
					ff[x][i] = min(x, cmn.first);
				} else {
					ff[x][i] = min(x, mn.first);
				}
			}
		} else {
			f[x] = 0;
			pair<int, int> mx, cmx;
			mx = cmx = make_pair(0, 0);
			for(int y : geta[x]){
				int tmp = 1e9;
				for(int i : sonb[y]){
					cal(i);
					tmp = min(tmp, f[i]);
				}
				cal(y);
				tmp = min(tmp, f[y]);
				int la = y, yy = y;
				for(int i = 1; i <= B; ++ i){
					yy = anc[yy];
					cal(yy);
					// if(x == 6 && y == 8){
						// printf("%d %d %d\n", yy, la, ff[yy][la]);
					// }
					tmp = min(tmp, ff[yy][la]);
					la = yy;
				}
				// if(x == 6){
					// printf("%d %d %d %d\n", x, y, getaa[y], tmp);
				// }
				if(getaa[y] == mx.second){
					mx.first = max(mx.first, tmp);
				} else if(make_pair(tmp, getaa[y]) >= mx){
					cmx = mx;
					mx = make_pair(tmp, getaa[y]);
				} else {
					cmx = max(cmx, make_pair(tmp, getaa[y]));
				}
			}
			f[x] = max(f[x], mx.first);
			for(int y : g[x]){
				if(y == anc[x]) continue;
				if(y == mx.second){
					ff[x][y] = cmx.first;
				} else {
					ff[x][y] = mx.first;
				}
				// if(x == 1 && y == 3) printf("%d %d %d %d\n", mx.first, cmx.first, mx.second ,cmx.second);
				if(ff[x][y] == 0){
					ff[x][y] = x;
				}
			}
		}
	}
	int main(){
		memset(f, 0x3f, sizeof(f));
		memset(ff, 0x3f, sizeof(ff));
		prdfs(st, 0);
		cal(st);
		printf("%d\n", f[st]);	
		return 0;
	}
}

int main(){
	freopen("nim.in", "r", stdin);
	freopen("nim.out", "w", stdout);
	scanf("%d%d%d%d", &n, &st, &A, &B);
	if(A <= B){
		puts("1");
		return 0;
	} else {
		int mx = 0;
		for(int i = 1; i < n; ++ i){
			int u, v;
			scanf("%d%d", &u, &v);
			g[v].push_back(u);
			g[u].push_back(v);
			mx = max(mx, (int)g[i].size());
		}
		if(mx <= 2 && g[st].size() == 1){
			solvelian::main();
		} else if(n <= 3000){
			solve2::main();
		}
	}
	return 0;
}